Interaktywne demonstracje
Należy wybrać jeden temat z pliku Mownit__ODE.pdf
Rozwiązaniem jest program pokazujący w interaktywny sposób rozwiązanie danego problemu obliczeniowego. Program powinien mieć graficzny interfejs użytkownika oraz umozliwiać dynamiczną interakcję poprzez zmianę parametrów. Język programowania oraz środowisko: dowolne. Proponowane rozwiązania:
Zadanie 2-tygodniowe
Model ten dzieli rozpatrywaną populację na trzy stany:
Liczba osób w danym stanie opisywana jest w funkcji czasu, odpowiednio I, S albo R. Jednocześnie w danym czasie t suma wartości tych trzech funkcji w tym punkcie czasu wynosi N (liczebność rozpatrywanej populacji). Model SIR bazuje na następujących równaniach różniczkowych, opisujących tempo przyrostu liczebności poszczególnych grup:

gdzie:
Stanowi ważny parametr opisu dynamiki epidemii. Określa on średnią liczbę osób zakażonych przez jedną zainfekowaną osobę. $$R_{0}=\frac{\beta}{\gamma}$$
Osoby, które przebyły chorobę COVID-19, wykształcają odporność trwającą przez co najmniej 5-7 miesięcy. Stanowi to na tyle długi okres czasu, że tzw. "ozdrowieńców" zakwalifikować można do grupy R, co umożliwia zastosowanie modelu SIR w badaniu przebiegu epidemii SARS-COV-2.
using DifferentialEquations
# using Plotly
using Plots
# plotly()
# Plots.PlotlyBackend()
# using PlotlyBase
# using PyPlot
function parameterized_derivative!(du, u, p, t)
S, I, R = u
beta, gamma, N = p
du[1] = -beta * S * I / N
du[2] = beta * S * I / N - gamma * I
du[3] = gamma * I
end
parameterized_derivative! (generic function with 1 method)
function SIR_computations(parameters, variables, days)
beta = parameters[1]
gamma = parameters[2]
N = parameters[3]
I0 = variables[1]
R0 = variables[2]
S0 = variables[3]
# Define differential equation problem
u0 = [S0; I0; R0]
tspan = (0.0, days)
params = [ beta, gamma, N]
prob = ODEProblem(parameterized_derivative!, u0, tspan, params);
alg = RK4()
# Solve system of differential equations
sol = solve(prob, alg);
return sol
end
SIR_computations (generic function with 1 method)
# Define model parameters
N = 1000.0
beta = 0.15
gamma = 1.0/21.0
# Define population
I0 = 1;
R0 = 0;
S0 = N - I0 - R0;
parameters = (beta, gamma, N)
variables = (I0, R0, S0)
days = 200.0
# Perform computations
result = SIR_computations(parameters, variables, days)
# Plot results
plot1 = Plots.plot(result, vars=[(0,1), (0,2), (0,3)], title="SIR Model:\n beta = 0.15, gamma = 1/21",
xaxis="Time [days]", yaxis="Population", marker=0.01, label=["Susceptible (S)" "Infected (I)" "Removed (R)"],
xticks = 0:25:200, yticks = 0:100:1000)
# Define model parameters
N = 1000.0
beta = 0.15
gamma = 1.0/14.0
# Define population
I0 = 1;
R0 = 0;
S0 = N - I0 - R0;
parameters = (beta, gamma, N)
variables = (I0, R0, S0)
days = 200.0
# Perform computations
result = SIR_computations(parameters, variables, days);
# Plot results
plot2 = Plots.plot(result, vars=[(0,1), (0,2), (0,3)], title="SIR Model:\n beta = 0.15, gamma = 1/14",
xaxis="Time [days]", yaxis="Population", marker=0.01, label=["Susceptible (S)" "Infected (I)" "Removed (R)"],
xticks = 0:25:200, yticks = 0:100:1000)
Plots.plot(plot1, plot2, layout=(1,2), size=(1100,500))
Zestawienie powyższych wykresów ilustruje zależność dynamiki przebiegu epidemii od czasu zdrowienia. Przyglądając się punktowi tzw. odporności zbiorowej, przyjmowanej jako R=70%, widać, że jest jest ona osiągana szybiej, gdy czas zdrowienia jest dłuższy (21 dni w porównaniu do 14 dni). Dzieje się tak ponieważ osobniki zakażone mają szansę zarażać dłużej, zanim wyzdrowieją, zatem fala zakażeń ma bardziej dynamiczny przebieg, większa liczba osób szybciej przechoruje, w konsekwencji czego odporność zbiorowa zostanie uzyskana szybciej.
# using IJulia
# using Conda
# using Interact
# using WebIO
# WebIO.install_jupyter_labextension()
#notebook(dir = Interact.notebookdir)
# using WebIO
# WebIO.install_jupyter_labextension(condajl=true)
using Mux
#WebIO.webio_serve(page("/", req -> ui), rand(8000:9000))
WebIO.webio_serve(page("/", req -> ui), 9000)
Task (runnable) @0x000000008367ea40
using Interact
using Blink
ui = button("Hi")
#display(ui)
w = Window()
o = observe(ui)
o[]
on(println, o)
on(n -> println(3+3), o)
o[] = 33;
t = textbox()
body!(w, ui);
33 6 34 6 34 6
# Define population
I0 = 1;
R0 = 0;
days = 200.0
import Colors
using Plots
function mycolorpicker()
N = slider(1:1000, label = "N")
beta = slider(0:0.01:1, label = "beta")
gamma = slider(0:0.01:1, label = "gamma")
parameters = Interact.@map (&beta, &gamma, &N)
S0 = Interact.@map &N - I0 - R0;
variables = Interact.@map (I0, R0, &S0)
output = Interact.@map SIR_computations(¶meters, &variables, days);
plt = Interact.@map plot(&output, vars=[(0,1), (0,2), (0,3)], title="SIR Model:\n beta = 0.15, gamma = 1/14",
xaxis="Time [days]", yaxis="Population", marker=0.01, label=["Susceptible (S)" "Infected (I)" "Removed (R)"],
xticks = 0:25:200, yticks = 0:100:1000)
wdg = Widget(["N" => N, "beta" => beta, "gamma" => gamma], output = output)
@layout! wdg hbox(plt, vbox(:N, :beta, :gamma), plt) ## custom layout: by default things are stacked vertically
end
mycolorpicker (generic function with 1 method)
ui = mycolorpicker()
o=Observable(ui)
ui
#using Blink
#w = Window()
#body!(w, ui)
Error handling websocket connection: TaskFailedException Stacktrace: [1] wait @ .\task.jl:317 [inlined] [2] create_socket(req::Dict{Any, Any}) @ WebIO ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:47 [3] (::Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)})(f::Function, x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:17 [4] (::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}})(x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [5] splitquery(app::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\basics.jl:31 [6] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [7] wcatch(app::Mux.var"#1#2"{typeof(Mux.splitquery), Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\websockets_integration.jl:12 [8] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [9] todict @ ~\.julia\packages\Mux\3h8RY\src\basics.jl:25 [inlined] [10] #3 (repeats 2 times) @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:14 [inlined] [11] (::Mux.var"#1#2"{Mux.var"#3#4"{Mux.var"#3#4"{typeof(Mux.todict), typeof(Mux.wcatch)}, typeof(Mux.splitquery)}, Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}})(x::Tuple{HTTP.Messages.Request, WebSockets.WebSocket{Sockets.TCPSocket}}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [12] (::Mux.var"#9#10"{Mux.App})(req::HTTP.Messages.Request, client::WebSockets.WebSocket{Sockets.TCPSocket}) @ Mux ~\.julia\packages\Mux\3h8RY\src\server.jl:49 [13] upgrade(f::Mux.var"#9#10"{Mux.App}, stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:201 [14] (::WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:370 [15] macro expansion @ ~\.julia\packages\HTTP\IAI92\src\Servers.jl:367 [inlined] [16] (::HTTP.Servers.var"#13#14"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() @ HTTP.Servers .\task.jl:406 nested task error: WebSockets.WebSocketClosedError("ws|server respond to OPCODE_CLOSE 1001: Going Away") Stacktrace: [1] handle_control_frame(ws::WebSockets.WebSocket{Sockets.TCPSocket}, wsf::WebSockets.WebSocketFragment) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:376 [2] read(ws::WebSockets.WebSocket{Sockets.TCPSocket}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:459 [3] macro expansion @ ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:41 [inlined] [4] (::WebIO.var"#110#111"{WebIO.WebSockConnection, WebSockets.WebSocket{Sockets.TCPSocket}})() @ WebIO .\task.jl:406┌ Error: (Base.IOError("read: connection reset by peer (ECONNRESET)", -4077), Base.StackTraces.StackFrame[wait_readnb(x::Sockets.TCPSocket, nb::Int64) at stream.jl:394, eof at stream.jl:106 [inlined], read_to_buffer(t::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, sizehint::Int64) at ConnectionPool.jl:251, readuntil(t::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, f::Function, sizehint::Int64) at ConnectionPool.jl:271, readuntil at ConnectionPool.jl:269 [inlined], readheaders at Messages.jl:471 [inlined], startread(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at Streams.jl:155, handle_transaction(f::WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, t::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, server::HTTP.Servers.Server{Nothing, Sockets.TCPServer}; final_transaction::Bool) at Servers.jl:343, (::HTTP.Servers.var"#handle_transaction##kw")(::NamedTuple{(:final_transaction,), Tuple{Bool}}, ::typeof(HTTP.Servers.handle_transaction), f::Function, t::HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, server::HTTP.Servers.Server{Nothing, Sockets.TCPServer}) at Servers.jl:338, handle_connection(f::Function, c::HTTP.ConnectionPool.Connection{Sockets.TCPSocket}, server::HTTP.Servers.Server{Nothing, Sockets.TCPServer}, reuse_limit::Int64, readtimeout::Int64) at Servers.jl:299, (::HTTP.Servers.var"#8#9"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.Servers.Server{Nothing, Sockets.TCPServer}, Base.RefValue{Int64}, Int64, Int64, Bool, HTTP.ConnectionPool.Connection{Sockets.TCPSocket}})() at task.jl:406]) └ @ HTTP.Servers C:\Users\basia\.julia\packages\HTTP\IAI92\src\Servers.jl:264
using Plots
using InteractBulma
# Define population
I0 = 1;
R0 = 0;
days = 200.0
timer = Observable(0.0)
@async while true
sleep(0.1)
timer[] = timer[]+0.1
end
Ns = slider(1:1000; label = "N")
betas = slider(0:0.01:1; label = "beta")
gammas = slider(0:0.01:1; label = "gamma")
ui2 = @manipulate for N in Ns, beta in betas, gamma in gammas, t=timer
parameters = @. (beta, gamma, N)
S0 = @. (N - I0 - R0)
variables = @. (I0, R0, S0)
output = @. SIR_computations(parameters, variables, days);
plot(output)
end
ui2
#=
import Colors
using Plots
function mycolorpicker()
N = slider(1:1000, label = "N")
beta = slider(0:0.01:1, label = "beta")
gamma = slider(0:0.01:1, label = "gamma")
parameters = Interact.@map (&beta, &gamma, &N)
S0 = Interact.@map &N - I0 - R0;
variables = Interact.@map (I0, R0, &S0)
output = Interact.@map SIR_computations(¶meters, &variables, days);
plt = Interact.@map plot(&output, vars=[(0,1), (0,2), (0,3)], title="SIR Model:\n beta = 0.15, gamma = 1/14",
xaxis="Time [days]", yaxis="Population", marker=0.01, label=["Susceptible (S)" "Infected (I)" "Removed (R)"],
xticks = 0:25:200, yticks = 0:100:1000)
wdg = Widget(["N" => N, "beta" => beta, "gamma" => gamma], output = output)
@layout! wdg hbox(plt, vbox(:N, :beta, :gamma), plt) ## custom layout: by default things are stacked vertically
end
=#
BoundsError
Stacktrace:
[1] getindex
@ .\number.jl:96 [inlined]
[2] SIR_computations(parameters::Float64, variables::Int64, days::Float64)
@ Main .\In[3]:3
[3] _broadcast_getindex_evalf
@ .\broadcast.jl:648 [inlined]
[4] _broadcast_getindex
@ .\broadcast.jl:621 [inlined]
[5] #19
@ .\broadcast.jl:1098 [inlined]
[6] ntuple
@ .\ntuple.jl:50 [inlined]
[7] copy
@ .\broadcast.jl:1098 [inlined]
[8] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(SIR_computations), Tuple{Tuple{Float64, Float64, Int64}, Tuple{Int64, Int64, Int64}, Float64}})
@ Base.Broadcast .\broadcast.jl:883
[9] (::var"#343#344")(N::Int64, beta::Float64, gamma::Float64)
@ Main .\In[150]:24
[10] map(::Function, ::Widget{:slider, Int64}, ::Widget{:slider, Float64}, ::Widget{:slider, Float64}, ::Vararg{Any, N} where N)
@ Observables ~\.julia\packages\Observables\Yf3xU\src\Observables.jl:365
[11] top-level scope
@ ~\.julia\packages\Widgets\0HInz\src\manipulate.jl:25
[12] eval
@ .\boot.jl:360 [inlined]
[13] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1094
using Plots
timer = Observable(0.0)
@async while true
sleep(0.1)
timer[] = timer[]+0.1
end
x = y = 0:0.1:30
freqs = OrderedDict(zip(["pi/4", "π/2", "3π/4", "π"], [π/4, π/2, 3π/4, π]))
ui2 = @manipulate for freq1 in freqs, freq2 in slider(0.01:0.1:4π; label="freq2"), t=timer
y = @. [sin(freq1*x.+t) sin(freq1*x)]
plot(x, y)
end
ui2
width, height = 700, 300
colors = ["black", "gray", "silver", "maroon", "red", "olive", "yellow", "green", "lime", "teal", "aqua", "navy", "blue", "purple", "fuchsia"]
color(i) = colors[i%length(colors)+1]
ui = @manipulate for nsamples in 1:200,
sample_step in slider(0.01:0.01:1.0, value=0.1, label="sample step"),
phase in slider(0:0.1:2pi, value=0.0, label="phase"),
radii in 0.1:0.1:60
cxs_unscaled = [i*sample_step + phase for i in 1:nsamples]
cys = sin.(cxs_unscaled) .* height/3 .+ height/2
cxs = cxs_unscaled .* width/4pi
dom"svg:svg[width=$width, height=$height]"(
(dom"svg:circle[cx=$(cxs[i]), cy=$(cys[i]), r=$radii, fill=$(color(i))]"()
for i in 1:nsamples)...
)
end
Error handling websocket connection: TaskFailedException Stacktrace: [1] wait @ .\task.jl:317 [inlined] [2] create_socket(req::Dict{Any, Any}) @ WebIO ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:47 [3] (::Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)})(f::Function, x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\┌ Error: error handling request │ exception = (Base.IOError("stream is closed or unusable", 0), Base.StackTraces.StackFrame[check_open at stream.jl:386 [inlined], uv_write_async(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64) at stream.jl:1018, uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64) at stream.jl:981, unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64) at stream.jl:1064, unsafe_write at ConnectionPool.jl:171 [inlined], write at io.jl:185 [inlined], closebody at Streams.jl:113 [inlined], closewrite(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at Streams.jl:128, (::HTTP.Servers.var"#13#14"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at task.jl:406]) └ @ HTTP.Servers C:\Users\basia\.julia\packages\HTTP\IAI92\src\Servers.jl:373 Mux.jl:17 [4] (::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}})(x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [5] splitquery(app::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\basics.jl:31 [6] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [7] wcatch(app::Mux.var"#1#2"{typeof(Mux.splitquery), Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\websockets_integration.jl:12 [8] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [9] todict @ ~\.julia\packages\Mux\3h8RY\src\basics.jl:25 [inlined] [10] #3 (repeats 2 times) @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:14 [inlined] [11] (::Mux.var"#1#2"{Mux.var"#3#4"{Mux.var"#3#4"{typeof(Mux.todict), typeof(Mux.wcatch)}, typeof(Mux.splitquery)}, Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}})(x::Tuple{HTTP.Messages.Request, WebSockets.WebSocket{Sockets.TCPSocket}}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [12] (::Mux.var"#9#10"{Mux.App})(req::HTTP.Messages.Request, client::WebSockets.WebSocket{Sockets.TCPSocket}) @ Mux ~\.julia\packages\Mux\3h8RY\src\server.jl:49 [13] upgrade(f::Mux.var"#9#10"{Mux.App}, stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:201 [14] (::WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:370 [15] macro expansion @ ~\.julia\packages\HTTP\IAI92\src\Servers.jl:367 [inlined] [16] (::HTTP.Servers.var"#13#14"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() @ HTTP.Servers .\task.jl:406 nested task error: WebSockets.WebSocketClosedError("ws|server respond to OPCODE_CLOSE 1001: Going Away") Stacktrace: [1] handle_control_frame(ws::WebSockets.WebSocket{Sockets.TCPSocket}, wsf::WebSockets.WebSocketFragment) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:376 [2] read(ws::WebSockets.WebSocket{Sockets.TCPSocket}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:459 [3] macro expansion @ ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:41 [inlined] [4] (::WebIO.var"#110#111"{WebIO.WebSockConnection, WebSockets.WebSocket{Sockets.TCPSocket}})() @ WebIO .\task.jl:406
35 6
Error handling websocket connection: TaskFailedException Stacktrace: [1] wait @ .\task.jl:317 [inlined] [2] create_socket(req::Dict{Any, Any}) @ WebIO ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:47 [3] (::Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)})(f::Function, x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:17 [4] (::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}})(x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [5] splitquery(app::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\basics.jl:31 [6] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [7] wcatch(app::Mux.var"#1#2"{typeof(Mux.splitquery), Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\websockets_integration.jl:12 [8] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [9] todict @ ~\.julia\packages\Mux\3h8RY\src\basics.jl:25 [inlined] [10] #3 (repeats 2 times) @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:14 [inlined] [11] (::Mux.var"#1#2"{Mux.var"#3#4"{Mux.var"#3#4"{typeof(Mux.todict), typeof(Mux.wcatch)}, typeof(Mux.splitquery)}, Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}})(x::Tuple{HTTP.Messages.Request, WebSockets.WebSocket{Sockets.TCPSocket}}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [12] (::Mux.var"#9#10"{Mux.App})(req::HTTP.Messages.Request, client::WebSockets.WebSocket{Sockets.TCPSocket}) @ Mux ~\.julia\packages\Mux\3h8RY\src\server.jl:49 [13] upgrade(f::Mux.var"#9#10"{Mux.App}, stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:201 [14] (::WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:370 [15] macro expansion @ ~\.julia\packages\HTTP\IAI92\src\Servers.jl:367 [inlined] [16] (::HTTP.Servers.var"#13#14"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() @ HTTP.Servers .\task.jl:406 nested task error: WebSockets.WebSocketClosedError("ws|server respond to OPCODE_CLOSE 1001: Going Away") Stacktrace: [1] handle_control_frame(ws::WebSockets.WebSocket{Sockets.TCPSocket}, wsf::WebSockets.WebSocketFragment) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:376 [2] read(ws::WebSockets.WebSocket{Sockets.TCPSocket}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:459 [3] macro expansion @ ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:41 [inlined] [4] (::WebIO.var"#110#111"{WebIO.WebSockConnection, WebSockets.WebSocket{Sockets.TCPSocket}})() @ WebIO .\task.jl:406
loadbutton = filepicker()
hellobutton = button("Hello!")
goodbyebutton = button("Good bye!")
b = vbox( # put things one on top of the other
loadbutton,
hbox( # put things one next to the other
pad(1em, hellobutton), # to allow some white space around the widget
pad(1em, goodbyebutton),
)
)
display(ui)
Error handling websocket connection: TaskFailedException Stacktrace: [1] wait @ .\task.jl:317 [inlined] [2] create_socket(req::Dict{Any, Any}) @ WebIO ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:47 [3] (::Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)})(f::Function, x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:17 [4] (::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}})(x::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [5] splitquery(app::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\basics.jl:31 [6] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [7] wcatch(app::Mux.var"#1#2"{typeof(Mux.splitquery), Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}}, req::Dict{Any, Any}) @ Mux ~\.julia\packages\Mux\3h8RY\src\websockets_integration.jl:12 [8] #1 @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [inlined] [9] todict @ ~\.julia\packages\Mux\3h8RY\src\basics.jl:25 [inlined] [10] #3 (repeats 2 times) @ ~\.julia\packages\Mux\3h8RY\src\Mux.jl:14 [inlined] [11] (::Mux.var"#1#2"{Mux.var"#3#4"{Mux.var"#3#4"{typeof(Mux.todict), typeof(Mux.wcatch)}, typeof(Mux.splitquery)}, Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#31#32"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#21#22"{Mux.var"#25#26"{Symbol, Int64}}, Mux.var"#23#24"{String}}}}})(x::Tuple{HTTP.Messages.Request, WebSockets.WebSocket{Sockets.TCPSocket}}) @ Mux ~\.julia\packages\Mux\3h8RY\src\Mux.jl:10 [12] (::Mux.var"#9#10"{Mux.App})(req::HTTP.Messages.Request, client::WebSockets.WebSocket{Sockets.TCPSocket}) @ Mux ~\.julia\packages\Mux\3h8RY\src\server.jl:49 [13] upgrade(f::Mux.var"#9#10"{Mux.App}, stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:201 [14] (::WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\HTTP.jl:370 [15] macro expansion @ ~\.julia\packages\HTTP\IAI92\src\Servers.jl:367 [inlined] [16] (::HTTP.Servers.var"#13#14"{WebSockets.var"#_servercoroutine#11"{WebSockets.ServerWS}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() @ HTTP.Servers .\task.jl:406 nested task error: WebSockets.WebSocketClosedError("ws|server respond to OPCODE_CLOSE 1001: Going Away") Stacktrace: [1] handle_control_frame(ws::WebSockets.WebSocket{Sockets.TCPSocket}, wsf::WebSockets.WebSocketFragment) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:376 [2] read(ws::WebSockets.WebSocket{Sockets.TCPSocket}) @ WebSockets ~\.julia\packages\WebSockets\QcswW\src\WebSockets.jl:459 [3] macro expansion @ ~\.julia\packages\WebIO\Fy9h1\src\providers\mux.jl:41 [inlined] [4] (::WebIO.var"#110#111"{WebIO.WebSockConnection, WebSockets.WebSocket{Sockets.TCPSocket}})() @ WebIO .\task.jl:406
using CSV, DataFrames, Interact, Plots
loadbutton = filepicker()
columnbuttons = Observable{Any}(dom"div"())
data = Observable{Any}(DataFrame)
plt = Observable{Any}(plot())
map!(CSV.read, data, loadbutton)
function makebuttons(df)
buttons = button.(string.(names(df)))
for (btn, name) in zip(buttons, names(df))
map!(t -> histogram(df[name]), plt, btn)
end
dom"div"(hbox(buttons))
end
map!(makebuttons, columnbuttons, data)
ui = dom"div"(loadbutton, columnbuttons, plt)